/******************************************************************************
                         COPYRIGHT 1955-2008 by BUPT ISC.
                        北京邮电大学信息安全中心 版权所有
                           Web: http://www.bupt.edu.cn
 *******************************************************************************/
/*******************************************************************************
  文件名： digest.h
  项目：   
  模块：   common
  作者：   zhangweibing
  版本：   0.1
  创建于:  2009-03-25
  描述：
    生成摘要值

  修改历史：
  日期： 修改人： 修改描述：
  
 *********************************************************************************/

#ifndef md5_INCLUDED
#  define md5_INCLUDED

/*
 * This package supports both compile-time and run-time determination of CPU
 * byte order.  If ARCH_IS_BIG_ENDIAN is defined as 0, the code will be
 * compiled to run only on little-endian CPUs; if ARCH_IS_BIG_ENDIAN is
 * defined as non-zero, the code will be compiled to run only on big-endian
 * CPUs; if ARCH_IS_BIG_ENDIAN is not defined, the code will be compiled to
 * run on either big- or little-endian CPUs, but will run slightly less
 * efficiently on either one than if ARCH_IS_BIG_ENDIAN is defined.
 */

typedef unsigned char MD5_BYTE_T;       /* 8-bit byte */
typedef unsigned int MD5_WORD_T;        /* 32-bit word */

/* Define the state of the MD5 Algorithm. */
typedef struct MD5_STATE_S
{
    MD5_WORD_T count[2];	            /* message length in bits, lsw first */
    MD5_WORD_T abcd[4];		            /* digest buffer */
    MD5_BYTE_T buf[64];		            /* accumulate block */
} MD5_STATE_T;

#ifdef __cplusplus
extern "C" 
{
#endif

/* Initialize the algorithm. */
void initMD5(MD5_STATE_T *pms);

/* Append a string to the message. */
void appendMD5(MD5_STATE_T *pms, const MD5_BYTE_T *data, int nbytes);

/* Finish the message and return the digest. */
void finishMD5(MD5_STATE_T *pms, MD5_BYTE_T digest[16]);

/* 计算指定长度文件的md5值 */
void generateDigest(char acDigest[32], char *pcFile, long int lFileLength);
#ifdef __cplusplus
}                                       /* end extern "C" */
#endif

#endif                                  /* md5_INCLUDED */
